<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../../system/admin/top.jsp"%>
</head>
<body>
	<div class="container-fluid" id="main-container">
		<ul class="nav nav-tabs">
			<li><a href="<%=basePath%>acttask/todo.do">待办任务</a></li>
			<li class="active"><a href="<%=basePath%>acttask/historic.do">已办任务</a></li>
		</ul>
		<div id="page-content" class="clearfix">
			<div class="row-fluid">
				<div class="row-fluid">
					<!-- 检索  -->
					<form action="acttask/list.do" method="post" name="Form" id="Form">
						<table>
							<tr>
								<td><span class="input-icon"> <input
										autocomplete="off" id="nav-search-input" type="text"
										name="name" value="" placeholder="这里输入关键词" /> <i
										id="nav-search-icon" class="icon-search"></i>
								</span></td>
								<td style="vertical-align: top;"><select
									class="chzn-select" name="category" id="field2"
									data-placeholder="请选择"
									style="vertical-align: top; width: 120px;">
										<option value="0">选择分类</option>
										<option value="1">审核流程</option>
										<option value="2">采购流程</option>
										<option value="3">报销流程</option>
										<option value="4">请假流程</option>
								</select></td>
								<td style="vertical-align: top;"><button
										class="btn btn-mini btn-light" onclick="search();" title="检索">
										<i id="nav-search-icon" class="icon-search"></i>
									</button></td>
							</tr>
						</table>
						<!-- 检索  -->

						<table id="table_report" class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th>序号</th>
									<th>标题</th>
									<th>当前环节</th>
									<th>流程名称</th>
									<th>流程版本</th>
									<th>完成时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<!-- 开始循环 -->
								<c:choose>
									<c:when test="${not empty varList}">
										<c:forEach items="${varList}" var="var" varStatus="vs">
											<c:set var="task" value="${var.histTask}" />
											<c:set var="vars" value="${var.vars}" />
											<c:set var="procDef" value="${var.procDef}" />
											<c:set var="status" value="${var.status}" />
											<tr>
												<td class='center' style="width: 30px;">${vs.index+1}</td>
												<td>
													<a href="<%=basePath%>acttask/form.do?taskId=${task.id}&taskName=${task.name}&taskDefKey=${task.taskDefinitionKey}&procInsId=${task.processInstanceId}&procDefId=${task.processDefinitionId}&status=${status}">${vars.map.title}</a>
												</td>
												<td>
												<a target="_blank" href="<%=basePath%>act/diagram-viewer?processDefinitionId=${task.processDefinitionId}&processInstanceId=${task.processInstanceId}">${task.name}</a>
												</td>
												<td>${procDef.name}</td>
												<td><b title='流程版本号'>V: ${procDef.version}</b></td>
												<td><fmt:formatDate value="${task.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
												<td class="center">
													<a href="<%=basePath%>acttask/form.do?taskId=${task.id}&taskName=${task.name}&taskDefKey=${task.taskDefinitionKey}&procInsId=${task.processInstanceId}&procDefId=${task.processDefinitionId}&status=${status}">详情</a>
												</td>
											</tr>
										</c:forEach>
										<c:if test="${QX.cha == 0 }">
											<tr>
												<td colspan="100" class="center">您无权查看</td>
											</tr>
										</c:if>
									</c:when>
									<c:otherwise>
										<tr class="main_info">
											<td colspan="100" class="center">没有相关数据</td>
										</tr>
									</c:otherwise>
								</c:choose>
							</tbody>
						</table>
					</form>
				</div>
				
				<!-- PAGE CONTENT ENDS HERE -->
			</div>
			<!--/row-->
			
		</div>
		<!--/#page-content-->
	</div>
	<!--/.fluid-container#main-container-->

	<!-- 返回顶部  -->
	<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse"> <i
		class="icon-double-angle-up icon-only"></i>
	</a>

	<!-- 引入 -->
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/ace-elements.min.js"></script>
	<script src="static/js/ace.min.js"></script>

	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript"
		src="static/js/bootstrap-datepicker.min.js"></script>
	<!-- 日期框 -->
	<script type="text/javascript" src="static/js/bootbox.min.js"></script>
	<!-- 确认窗口 -->
	<!-- 引入 -->
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>
	<!--提示框-->
	<script type="text/javascript">
		
		$(top.hangge());
		
		//检索
		function search(){
			top.jzts();
			$("#Form").submit();
		}
		
		//新增
		function add(){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '<%=basePath%>goodtype/goAdd.do';
			 diag.Width = 450;
			 diag.Height = 355;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//激活
		function active(Id){
			bootbox.confirm("确认要激活吗？", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>actprocess/update/active?procDefId="+Id;
					$.get(url,function(data){
						location.reload();
					});
				}
			});
		}
		
		//挂起
		function suspended(Id){
			bootbox.confirm("确认要挂起吗？", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>actprocess/update/suspend?procDefId="+Id;
					$.get(url,function(data){
						location.reload();
					});
				}
			});
		}
		
		//删除
		function del(Id){
			bootbox.confirm("确认要删除该流程吗？", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>actprocess/delete.do?deploymentId="+Id;
					$.get(url,function(data){
						location.reload();
					});
				}
			});
		}
		
		//转换模型
		function convert(Id){
			bootbox.confirm("确认要转换为模型吗？", function(result) {
				if(result) {
					top.jzts();
					var url = "<%=basePath%>actprocess/toModel.do?procDefId="+Id;
					$.get(url,function(data){
						location.href = "<%=basePath%>actmodel/list.do";
					});
				}
			});
		}
		
		//修改
		function edit(Id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL = '<%=basePath%>goodtype/goEdit.do?good_type_id='+Id;
			 diag.Width = 450;
			 diag.Height = 355;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		</script>

	<script type="text/javascript">
		
		$(function() {
			
			//下拉框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
			
			//复选框
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});
			
		});
		
		
		//批量操作
		function makeAll(msg){
			bootbox.confirm(msg, function(result) {
				if(result) {
					var str = '';
					for(var i=0;i < document.getElementsByName('ids').length;i++)
					{
						  if(document.getElementsByName('ids')[i].checked){
						  	if(str=='') str += document.getElementsByName('ids')[i].value;
						  	else str += ',' + document.getElementsByName('ids')[i].value;
						  }
					}
					if(str==''){
						bootbox.dialog("您没有选择任何内容!", 
							[
							  {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback": function() {
									//Example.show("great success");
									}
								}
							 ]
						);
						
						$("#zcheckbox").tips({
							side:3,
				            msg:'点这里全选',
				            bg:'#AE81FF',
				            time:8
				        });
						
						return;
					}else{
						if(msg == '确定要删除选中的数据吗?'){
							top.jzts();
							$.ajax({
								type: "POST",
								url: '<%=basePath%>goodtype/deleteAll.do?tm='+new Date().getTime(),
						    	data: {DATA_IDS:str},
								dataType:'json',
								//beforeSend: validateData,
								cache: false,
								success: function(data){
									 $.each(data.list, function(i, list){
											nextPage(${page.currentPage});
									 });
								}
							});
						}
					}
				}
			});
		}
		
		//导出excel
		function toExcel(){
			window.location.href='<%=basePath%>goodtype/excel.do';
		}
		</script>
</body>
</html>